<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>addTicNum 升舱添加票号小弹窗</title>
	</head>
	<link rel="stylesheet" href="../css/common.css" />
	<style>
		body{
			background: #eeeeee;
		}
		.main{
			text-align:right;
			padding-top:28px;
			overflow:auto;
			width:330px;
		}
		input{
			height:27px;
			width:180px;
			border:1px solid #dadada;
			border-radius:3px;
			padding-left:10px;	
		}
		.main p{
			height:36px;
		}
		.main p>span{
			display:inline-block;
			text-align:left;
			width:200px;
		}
		.btnBox{
			height:50px;
			width:100%;
			position:fixed;
			bottom:0;
			left:0;
			text-align:center;
		}
		.sure,.cancel{
			height:28px;
			padding:0 35px;
			background:#00aa98;
			border:none;
			border-radius:3px;
			color:white;
			cursor:pointer;
			outline:0;
		}
		.cancel{
			margin-left:30px;
			background:#a1a4a9;
		}
	</style>
	<body>
		<div class='main'>
			<p>旅客姓名：<span class='name'></span></p>	
			<p>证件号：<span class='certificateNumber'></span></p>
			<p>票号：<span><input class='number'/></span></p>	
		</div>
		<div style='height:50px;'></div>
		<div class='btnBox'>
			<button class='sure'>确认</button>
			<button class='cancel'>取消</button>
		</div>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>	
		<script type="text/javascript" src="../layer-v2.4/layer/layer.js" ></script>	
		<script type="text/javascript" src="../js/common.js" ></script>
		
		<script>
		var name_passenger = getHref().name;
		var certificateNumber = getHref().certificateNumber;
		var number = getHref().number;
		var id = getHref().id;
		var orderId = getHref().orderId;
		var passengerKey = getHref().passengerKey;
		//_______________________________________________________________页面渲染
			$(".name").text(name_passenger);
			$(".certificateNumber").text(certificateNumber);
			$(".number").val(number);
		//_______________________________________________________________确定按钮				
			 $(".sure").click(function(){	
					var number = $(".number").val();
					if(!/^\d{3}(\-\d+)?\d{1,}$/.test(number)||number.length>18){
						layer.msg("票号格式不正确",{icon:2,time:1500});
						return false;
					}					
					layer.msg('添加票号中...', {icon: 16,shade: 0.01});					
					//将得到的数据传输给后台					
					 $.ajax({
							type:"post",
							url:"../orderAddon/updExchTkt?exchId="+orderId+"&passengerKey="+passengerKey+"&psgrId="+id+"&tktNum="+number,
							contentType:'application/json;charset=utf-8',
							async:true,
							success:function(data){
								var data=JSON.parse(data);								
								if(data.status.toString()=="1001"){
									layer.msg(data.message, {icon: 1,time:1000},function(){
										var index = parent.layer.getFrameIndex(window.name);//获取弹窗索引
										parent.layer.close(index);//关闭弹窗
									});			
								}else{
									layer.msg(data.message, {icon: 2,time:1000})
								}
							}
						});
					
					
				});
		
			
			
		//_______________________________________________________________取消按钮
			
			$(".cancel").click(function(){				
				var index = parent.layer.getFrameIndex(window.name);//获取弹窗索引
				parent.layer.close(index);//关闭弹窗
			})
		 
		
		</script>
	</body>
</html>
